<template>
  <div class="video" @click="toDetail(props.data.id)">
    <div style="width: 100%; height: 100%; position: relative">
      <el-image :src="props.data.firstImgUrl" class="video-img"></el-image>
      <div class="data-icon">
        <div class="icon-item">
          <img src="@/assets/icon/chakan3.png" alt="" class="sicon" />
          <div>{{ tool.numberTo(props.data.lookCount) }}</div>
        </div>
        <div class="icon-item">
          <img src="@/assets/icon/dianzan3.png" alt="" class="sicon" />
          <div>{{ tool.numberTo(props.data.thumbUp) }}</div>
        </div>
        <div class="icon-item">
          <img src="@/assets/icon/shoucang3.png" alt="" class="sicon" />
          <div>{{ tool.numberTo(props.data.collection) }}</div>
        </div>
      </div>
    </div>
    <div class="muti-ell-2 common-f-14 title">
      {{ props.data.title }}
    </div>
    <div class="video-bottom">
      <div style="display: flex; align-items: center">
        <img
          src="@/assets/icon/uper.png"
          alt=""
          class="sicon"
          style="margin-right: 5px"
        />
        <div>
          {{ props.data.user?.nickname || "未知" }}
        </div>
      </div>

      <!-- <div v-show="props.data.type === 2" class="gold">
        {{ props.data.gold }}金币
      </div> -->
      <div>
        <el-tag
          :type="tags[props.data?.type]?.label"
          :size="small"
          style="height: 20px"
        >
          {{ tags[props.data.type].name }}
        </el-tag>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, ref, defineEmits } from "vue";
import tool from "@/assets/js/tool";
import { useRouter } from "vue-router";

const props = defineProps({
  data: {
    type: Object,
    default: () => {},
  },
});

const emits = defineEmits(["change"]);

const router = useRouter();

const tags = ref({
  0: {
    name: "免费",
    label: "success",
  },
  1: {
    name: "会员",
    label: "danger",
  },
  2: {
    name: "金币",
    label: "warning",
  },
});

const toDetail = (id) => {
  if (router.currentRoute.value.path === "/client/detail") {
    emits("change", id);
  } else {
    router.push({
      path: "/client/detail",
      query: {
        vid: id,
      },
    });
  }
};
</script>

<style scoped lang="scss">
.video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom-right-radius: 5px;
  border-bottom-left-radius: 5px;
  &:hover {
    cursor: pointer;
  }
}

.title {
  width: 100%;
  text-align: left;
  padding: 2px 0;
  margin-left: 10px;
  min-height: 35px;
}
.data-icon {
  position: absolute;
  display: flex;
  justify-content: space-between;
  bottom: 4px;
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.3) 100%
  );
  .icon-item {
    display: flex;
    align-items: center;
    padding: 2px 5px;
    color: #fff;
    font-size: 12px;
  }
}
.video-img {
  width: 100%;
  height: 120px;
}

.video-bottom {
  display: flex;
  align-items: center;
  font-size: 14px;
  justify-content: space-between;
  width: 94%;
  line-height: 30px;

  .gold {
    background: #fdf6ec;
    padding: 0 6px;
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    color: #e7a848;
    border-radius: 3px;
  }
}
</style>
import { useRouter } from "vue-router";
